package com;

import com.bean.BeanA;
import com.bean.BeanB;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

public class MyUnderStandingOfLoopDependency {

    @DisplayName("我自己对spring三级缓存解决循环依赖的理解")
    @Test
    void testMyUnderstanding() {
        final MyBeanFactory beanFactory = new MyBeanFactory();


        beanFactory.registerBean(BeanA.class);
        beanFactory.registerBean(BeanB.class);

        beanFactory.preInstantiateSingletons();

        BeanA beanA = (BeanA) beanFactory.getBean(BeanA.class.getName());

        BeanB beanB = (BeanB) beanFactory.getBean(BeanB.class.getName());

        Assertions.assertEquals(beanA.getBeanB(), beanB);

        Assertions.assertEquals(beanB.getBeanA(), beanA);
    }

}
